/**
 * 
 */
package edu.university.demo.system.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import edu.university.demo.system.entit.Song;


/**
 * 歌曲CRUD接口
 * 
 * @author mayanping
 *
 */
public interface SongDao extends PagingAndSortingRepository<Song, Long>, JpaSpecificationExecutor<Song> {
	
	public List<Song> getSongListByReleaseDate(Date releaseDate);
	
	/**
	 * 
	 * HQL和SQL语句的异同：
	 * SQL语句用于操作数据库表结构，
	 * HQL用于操作对象，entity包下的实体对象
	 * */
	@Query(" from Song song where song.singer = ?1")
	public List<Song> getSongListBySinger(String singer);
	
	@Query("select s from Song s  join s.userList u where u.loginName  = ?1")
	public List<Song> getSongListByAccount(String account);
	
	/**
	 * 倒序查询所有歌曲
	 * */ 
	@Query("from Song  order by id desc")
	public List<Song> findAllSongs();
}
